﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "GmUiStructure.h"
#include "UniIdentity.h"
#include "ElementId.h"

namespace gcmp
{
    class IDocument;
    class IModelView;
    class IModelLine;
    class IFamilyType;
    class IControlDefinition;

    struct StructureBeamInput;
    struct StructureWallInput;
    struct StructureColumnInput;
    struct StructureWallHoleInput;
    struct StructureProfileInstanceElementInput;
    struct StructureRaftFoundationElementInput;
    struct StructurePlateHoleElementInput;
    struct StructureRoofInput;
    struct StructureStripFoundationInput;
    
    enum class LineFamilyPositionCurveSideType;
    enum class InstancePlacementTypes;

    class GM_UI_STRUCTURE_EXPORT StructureInstanceCmdUtils
    {
    public:
        // 生成结构梁的input数据
        static bool GenerateStraightBasicBeamInput(IDocument* pDoc, IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructureBeamInput& input);

        static bool GenerateStraightVariableSectionBeamInput(IDocument* pDoc, IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructureBeamInput& input);

        static bool GenerateArcBy3PtsBasicBeamInput(IDocument* pDoc, IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructureBeamInput& input);

        // 生成结构墙的input数据
        static bool GenerateBasicWallInput(IDocument* pDoc, IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructureWallInput& input);

        static bool GenerateStraightVariableSectionWallInput(IDocument* pDoc, IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructureWallInput& input);

        // 生成结构柱的input数据
        static bool GenerateVerticalColumnInput(IDocument* pDoc, IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructureColumnInput& input);

        static bool GenerateSlantedColumnInput(IDocument* pDoc, IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructureColumnInput& input);

        // 生成结构板的input数据
        static bool GenerateStructurePlateInput(IDocument* pDoc, IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructureProfileInstanceElementInput& input);

        // 生成筏板基础的input数据
        static bool GenerateRaftFoundationInput(IDocument* pDoc, IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructureRaftFoundationElementInput& input);

        // 生成条形基础的input数据
        static bool GenerateStraightStructureStripFoundationInput(IDocument* pDoc, IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructureStripFoundationInput& input);

        // 生成板洞的input数据
        static bool GenerateStructurePlateHoleInput(IDocument* pDoc, IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructurePlateHoleElementInput& input);

        // 生成墙洞的input数据
        static bool GenerateStructureWallHoleInput(IDocument* pDoc, const IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructureWallHoleInput& input);

        // 生成结构板的input数据
        static bool GenerateStructureRoofInput(IDocument* pDoc, IModelView* pModelView,
            const UniIdentity& category, Int32 categorySecondKey, ElementId familyId, ElementId instanceTypeId,
            StructureRoofInput& input);

        // 临时添加，等所有相关action改造结束再替换掉AddYPositionInputItemsToDialog
        static bool AddYPositionInputItemsToDialogNew(const std::wstring& eventId, LineFamilyPositionCurveSideType yPositioningType,
            std::vector<gcmp::OwnerPtr<gcmp::IControlDefinition>>& inputItems);

        // 从对话框中获取Y轴定位位置
        static bool GetYPositionFromInputEvent(int inputValue, LineFamilyPositionCurveSideType& yPositioningType);

        // 临时添加，等所有相关action改造结束再替换掉GetYPositionFromInputEvent
        static bool GetYPositionFromInputEventNew(const std::wstring& inputValue, LineFamilyPositionCurveSideType& yPositioningType);

        // 获取放置类型
        static bool GetInstancePlacementType(const IFamilyType* pFamilyType, InstancePlacementTypes& posType);

        // 获取子类别
        static bool GetCategorySubType(const IFamilyType* pFamilyType, int& categorySubType);
    };
}
